<include file="Public:header" />
<!--主体内容-->
<!--左边-->
<div class="centent_box">
    <include file="Public:left" />
    <!--右边-->
    <div class="centent_right_box">
        <div class="centent_right rightCon">
            <div class="Mtitle">
                <ul>
                    <li class="on"><span>系统管理</span></li>
                </ul>
                <div class="rightWord"><a href="{:U('Set/dict')}">数据字典</a> &gt;&gt; 新增字典</div>
            </div>
            <form id="info_form" action="{:U('Set/add_dict')}" method="post" >
            <div class="con_div">
                <ul class="formList width2 list_ul list_mp">
                    <li class="clear" id="area-sele">
                        <label>区域范围：</label>
                        <select class="selectStyle area" name="dd" id="area" onclick="getArea(this)" onchange="seleArea(this)">
                            <option value="0">--请选择--</option>
                            <option value="1">深圳</option>
                        </select>

                    </li>
                    <li class="clear">
                        <label>选择小区：</label>
                        <select class="selectStyle" name="data[estate_id]" id="estate">
                            <option value="0">--请选择--</option>
                        </select>

                    </li>
                    <li>
                        <label>栋：</label>
                        <select class="selectStyle" name="data[build]" id="build">
                            <option value="0">--请选择--</option>
                        </select>
                        <label>别名：</label>
                        <input type="text" class="inputStyle width2"  name="data[build_name]">
                    </li>
                    <li>
                        <label>单元：</label>
                        <select class="selectStyle" name="data[unit]" id="unit">
                            <option value="0">--请选择--</option>
                        </select>
                        <label>别名：</label>
                        <input type="text" class="inputStyle width2"  name="data[unit_name]">
                    </li>
                    <li>
                        <label>层：</label>
                        <select class="selectStyle" name="data[fool]" id="floor">
                            <option value="0">--请选择--</option>
                        </select>
                        <label>别名：</label>
                        <input type="text" class="inputStyle width2"  name="data[floor_name]">
                    </li>
                    <li>
                        <label>房间：</label>
                        <select class="selectStyle" name="data[room]" id="room">
                            <option value="0">--请选择--</option>
                        </select>
                        <label>别名：</label>
                        <input type="text" class="inputStyle width2"  name="data[room_name]">
                    </li>

                    <li class="clear">
                        <label>户型：</label>
                        <select class="selectStyle" name="data[house_type]" >
                            <option value="0">--请选择--</option>
                            <volist name="house_type" id="vo">
                                <option value="{$vo.type_title}">{$vo.type_title}</option>
                            </volist>
                        </select>
                        <label>面积：</label>
                        <input type="number" class="inputStyle width2" name="data[area]" >
                        <span class="tip">平方米</span>
                    </li>
                    <li class="dict-info">
                        <label >地址：</label>
                        <input type="text"  name="data[addr]"  class="inputStyle width3">
                    </li>
                    <li class="li_radio">
                        <label class="lw90">朝向：</label>
                        <input type="radio" name="data[aspect]" id="orientations109" value="10"><label for="orientations109">西北</label>
                        <input type="radio" name="data[aspect]" id="orientations108" value="9"><label for="orientations108">西南</label>
                        <input type="radio" name="data[aspect]" id="orientations107" value="8"><label for="orientations107">东北</label>
                        <input type="radio" name="data[aspect]" id="orientations106" value="7"><label for="orientations106">东南</label>
                        <input type="radio" name="data[aspect]" id="orientations105" value="6"><label for="orientations105">南北</label>
                        <input type="radio" name="data[aspect]" id="orientations104" value="5"><label for="orientations104">东西</label>
                        <input type="radio" name="data[aspect]" id="orientations103" value="4"><label for="orientations103">北</label>
                        <input type="radio" name="data[aspect]" id="orientations102" value="3"><label for="orientations102">南</label>
                        <input type="radio" name="data[aspect]" id="orientations101" value="2"><label for="orientations101">西</label>
                        <input type="radio" name="data[aspect]" id="orientations100" value="1"><label for="orientations100">东</label>
                    </li>
                    <li class="li_radio">
                        <label class="lw90">装修状况：</label>
                        <input type="radio" name="data[decorate]" id="decorate1" value="10"><label for="decorate1">土坯</label>
                        <input type="radio" name="data[decorate]" id="decorate2" value="9"><label for="decorate1">简装</label>
                        <input type="radio" name="data[decorate]" id="decorate3" value="8"><label for="decorate1">精装</label>
                        <input type="radio" name="data[decorate]" id="decorate4" value="7"><label for="decorate1">豪装</label>
                    </li>

                    <li id="files">
                        <label>多图上传：</label>
                        <script id="uploadpic" name="uploadpic" type="text/plain"></script>
                        <input type="button" class="btn btn_submit" style="margin:0 0 10px 10px;" onclick="upImage();" value="选择图片">
                        <div id="imageList">
                            <ul class="list clearfix"></ul>
                        </div>
                        <input type="hidden" name="file" id="file" />
                    </li>


                    <li>
                        <input type="hidden" name="dat" id="res-area">
                    </li>
                    <li>
                        <label></label>
                        <input type="submit" value="提 交" class="btnStyle">
                    </li>
                </ul>
            </div>
            </form>
        </div>
    </div>
</div>
<js file="__S__/ueditor/ueditor.config.js" charset="utf-8" />
<js file="__S__/ueditor/ueditor.all.min.js" charset="utf-8" />
<js file="__S__/ueditor/lang/zh-cn/zh-cn.js" charset="utf-8" />
<js file="__JS__/uploadImg.js" charset="utf-8" />
<script type="text/javascript">
    window.UEDITOR_HOME_URL='__STATIC__/ueditor/';
    window.onload=function(){
        window.UEDITOR_CONFIG.initialFrameWidth=880;
        window.UEDITOR_CONFIG.initialFrameHeight=500;
        upmoreimg();
    }
    var ue = UE.getEditor('info', {
        toolbars: [[
            'fullscreen', 'source', '|',
            'bold', 'italic', 'underline', '|', 'fontfamily','fontsize', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', 'simpleupload','|', 'kityformula', 'preview'
        ]]
    });
</script>
<script src="__S__/js/jquery.validate.js"></script>
<script type="text/javascript">
    $(function(){
        $("#info_form").validate({
            rules: {
                "data[title]": {
                    required: true,
                    minlength: 2
                },
                "data[area_id]": {
                    area:true
                },
                "data[area]": {
                    required: true,
                    minlength: 2
                },
                "data[floor]": {
                    required: true
                },

            },
            messages: {
                "data[title]": {
                    required: "请输入房源名称",
                    minlength: "房源名称一定要两个字以上"
                },
                "data[area]": {
                    required: "请输入房源面积",
                    minlength: "房源面积一定要两个字以上"
                },
                "data[floor]": {
                    required: "请填写所在楼层"
                },
            }
        });

        //所属地区
        $.validator.addMethod("area", function(value, element) {
           if($("#area_id").val()!=0){
               return true
           }else{
               return false
           }
        }, "请选择所属地区");
    });
    function getArea (tar){
        var areaid = $(tar).val();
        var sele = $(tar);
        if (areaid == 0) {
            $(sele).nextAll('select').remove();
            $('#estate option[value=0]').nextAll('option').remove();
            return false;
        }
        var url = "{:U('Ajax/getArea')}", data = {areaid:areaid};
        $.post (url, data, function (response){
            var html = '';
            if (response.state == 'ok'){
                var data = response.data;
                html = '<select class="selectStyle area" name="area" onclick="getArea(this)" onchange="seleArea(this)"><option value="0">--请选择--</option>';
                $.each(data, function (i, v){
                    html += '<option value="'+v.id+'">'+v.name+'</option>';
                });
                html += '</select>';
            }
            $(sele).nextAll('select').remove();
            $('#area-sele').append(html);
        }, 'json');
    }
    function seleArea(tar) {
        var sele_val = $(tar).val();
        var url = "{:U('Ajax/getEstate')}";
        var data = {area_id:sele_val};
        $.post (url, data, function (response){
            if (response.status == 1){
                var html = '';
                var data = response.data;
                $.each (data, function (i,v){
                    html += '<option value="'+v.id+'">'+v.title+'</option>';
                });
                $('#estate option[value=0]').nextAll('option').remove();
                $('#estate').append(html);
            }
        },'json');
    };
    $('#estate').change(function (){
        var eid = $(this).val();
        var url = "{:U('Ajax/getEstates')}";
        var data = {eid:eid};
        $.post (url, data, function (response){
            if (response.state == 'ok'){
                var data = response.data;
                for_sele ('build', data.build);
                for_sele ('unit', data.unit);
                for_sele ('floor', data.floor);
                for_sele ('room', data.room);
            }
        },'json');
    });
    function for_sele (id, count_){
        var html = '';
        if (id == 'build') var unit = '栋';
        if (id == 'unit') var unit = '单元';
        if (id == 'floor') var unit = '层';
        if (id == 'room') var unit = '房';
        for (var i=1; i<= count_; i++){
            html += '<option value="'+i+'">'+i+unit+'</option>';
        }
        $('#'+id+' option[value=0]').nextAll('option').remove();
        $('#'+id).append(html);
    }

</script>
<include file="Public:footer" />